<?php
/**
 * --------------------------------------------------------------------
 * 角色用户映射模型
 * --------------------------------------------------------------------
 * @author Midnight, yangyunzhou@foxmail.com
 * --------------------------------------------------------------------
 * @copyright Midnight Studio
 * --------------------------------------------------------------------
 */
class RoleUserModel extends RbacModel
{

    /**
     * 主键
     * @var String
     */
    public $pk = 'user_id';

    /**
     * 字段
     * @var Array
     */
    public $fields = array('role_id', 'user_id');

    /**
     * --------------------------------------------
     * 映射角色用户
     * --------------------------------------------
     * @author Midnight, yangyunzhou@foxmail.com
     * @param Int $role_id 角色ID
     * @param Int $user_id 用户ID
     * @param String $type 操作类型 (添加/保存)
     */
    public function set($role_id, $user_id, $type=FALSE)
    {
        if($type == FALSE) return false;
        $type = strtolower($type);
        $this->role_id = $role_id;
        $this->user_id = $user_id;
        if($type=='add') return $this->add();
        elseif($type=='save') return $this->save();
    }

}